﻿@model TraCuuThuatNgu.ViewModels.InfoViewModel
@{
    ViewBag.Title = "Cập nhật thông tin thành viên";
    Layout = "~/Views/Shared/_Admin.cshtml";
}
<style type="text/css">
    #Users
    {
        border-color: #143D6B;
        background: url("/Content/img/backgrounds/menu-item-active.jpg") left top repeat-x;
    }
</style>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<a href="/Users" class="btn-link"><h4 style="margin-top:0px">← Quay lại danh sách</h4></a>
<div class="span span12">
    <div class="head">
        <div class="icm-edit">
        </div>
        <h1>
            Thông tin tài khoản</h1>
        <div class="clear">
        </div>
    </div>
    <div class="block">
        @using (Html.BeginForm())
        {               
            @Html.HiddenFor(x => x.UserId)
            <div class="entry-form">
                <div class="editor">
                    <div class="editor-label">
                        Họ tên
                    </div>
                    <div class="editor-field">
                        @Html.TextBoxFor(x => x.Fullname)
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div class="editor">
                    <div class="editor-label">
                        Tên đăng nhập
                    </div>
                    <div class="editor-field">
                        @Html.HiddenFor(x => x.Username)
                        <b>@Model.Username</b>
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div class="editor">
                    <div class="editor-label">
                        Email
                    </div>
                    <div class="editor-field">
                        @Html.TextBoxFor(x => x.Email)
                        @Html.ValidationMessageFor(x => x.Email)
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div class="editor">
                    <div class="editor-label">
                        Ngày sinh
                    </div>
                    <div class="editor-field">
                        @if (ViewBag.Birthday != null)
                        {
                            <input value="@String.Format("{0:dd/MM/yyyy}", ViewBag.Birthday)" name="birthday" type="text" />
                        }
                        else
                        { 
                            <input value="" name="birthday" type="text" />
                        }
                        (dd/MM/yyyy)
                        <br />
                        Ví dụ: 30/03/1990
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div class="editor">
                    <div class="editor-label">
                        Quyền trong hệ thống
                    </div>
                    <div class="editor-field">
                        <ul class="roles-list">
                            @foreach (var role in ViewBag.Roles)
                            {
                                bool check = false;
                                foreach (var i in ViewBag.UserRoles)
                                {
                                    if (i == role)
                                    {
                                        check = true;
                                    }                                    
                                }
                                if (check)
                                { 
                                <li>
                                    <input type="checkbox" checked="checked" name="userRoles" value="@role" />
                                    @role</li>
                                }
                                else
                                { 
                                <li>
                                    <input type="checkbox" name="userRoles" value="@role" />
                                    @role</li>
                                }
                            }
                        </ul>
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div class="editor">
                    <div class="editor-label">
                    </div>
                    <div class="editor-field">
                        <input type="submit" class="btn" value="Cập nhật" />
                        <input type="button" id="btn-delete-user" class="btn btn-danger" value="Xóa" />
                        <input type="hidden" value="@Model.UserId" id="userId" />
                        <span style='color: green'>@ViewBag.Success</span> <span style='color: red'>@ViewBag.Fail</span>
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </div>   
        }
    </div>
</div>
